import { AmcaxRender, InteractionManager } from '@amcax/web-render';
import { create } from 'zustand';
type State = {
  mainRenderer: AmcaxRender;
};
type Action = {
  setMainRenderer: (renderer: AmcaxRender) => void;
  /**
   * 获取交互管理器，可用于register hover/select listener等
   * @returns
   */
  getInteractionManager: () => InteractionManager;
};

export const useRenderStore = create<State & Action>((set, get) => ({
  mainRenderer: null,
  setMainRenderer: (render: AmcaxRender) =>
    set(() => ({ mainRenderer: render })),
  getInteractionManager: () => get().mainRenderer?.interactionManager,
}));
